home *** CD-ROM | disk | FTP | other *** search
- #include "global.h"
- #include "magx.h"
- #include "obj.h"
- #include "printer.h"
- #include "rsc.h"
- #include "windows.h"
- #include "xfsl.h"
- #include "xufsl.h"
- #include "fontsel.h"
-
- /*
- * exportierte Variablen
- */
- FONTINFO winFont;
- FONTINFO druckFont;
- WORD sys_font_size;
- WORD sys_font_id;
- BOOLEAN extern_fontselect;
-
-
- LOCAL WORD set_fsize(WORD handle, WORD f_id, WORD f_size)
- {
- UBYTE size[32];
- WORD ret;
-
- vst_font(handle, f_id);
- f_size = vst_point (handle, f_size, &ret,&ret,&ret,&ret);
- itoa (f_size, size, 10);
- fill_ptext (fontsel, FGROESSE, size);
- return f_size;
- }
-
-
- LOCAL WORD next_fsize(WORD handle, WORD f_size)
- {
- WORD s, s_neu, s_old, ret;
-
- s = 1000;
- s_old = s_neu = vst_point (handle, s, &ret,&ret,&ret,&ret);
- while (s_neu>f_size)
- {
- s = min(s_neu-1,s-1);
- s_old = s_neu;
- s_neu = vst_point (handle, s, &ret,&ret,&ret,&ret);
- }
- return s_old;
- }
-
-
- LOCAL WORD prev_fsize(WORD handle, WORD f_size)
- {
- WORD s, s_neu, ret;
-
- s = f_size;
- s_neu = vst_point (handle, s, &ret,&ret,&ret,&ret);
- while (s_neu>=f_size)
- {
- s = min(s_neu-1,s-1);
- if (s<=0) return f_size;
- s_neu = vst_point (handle, s, &ret,&ret,&ret,&ret);
- }
- return s_neu;
- }
-
- BOOLEAN select_font(WORD handle)
- {
- FONTINFO *font;
- BOOLEAN show_font;
- WORD antw, f_id, f_size, f_nr, i, d, ret;
- UBYTE name[34], *titel;
- DIALINFO dial;
-
- Arrow_mouse();
- if (handle == vdi_handle) /* Bildschirmfont? */
- {
- show_font = TRUE;
- font = &winFont;
- titel = STRING(SELWFONTSTR);
- }
- else
- {
- show_font = FALSE;
- font = &druckFont;
- titel = STRING(SELPFONTSTR);
- }
-
- f_id = font->ID;
- f_size = font->Size;
-
- if (extern_fontselect)
- {
- LONG v;
-
- if (getcookie('xFSL', &v))
- {
- xFSL *xfsl;
-
- xfsl = (xFSL *)v;
- ret = xfsl->fsl_input(0, (FF_ALL), titel, &f_id, &f_size);
- if (ret == 1)
- {
- font->ID = f_id;
- font->Size = f_size;
- for (d = 1; d <= 100; d++)
- if (font->ID == vqt_name(handle, d, font->Name))
- {
- font->Index = d;
- break;
- }
- return TRUE;
- }
- return FALSE;
- }
- else if (getcookie('UFSL', &v))
- {
- xUFSL_struct *ufsl;
- ULONG flags=0xFFFF;
- WORD attr = 0, color = 1, skew = 0;
- FW_INFO width={0,0,0};
-
- ufsl = (xUFSL_struct *)v;
- flags = UFS_SIZE_CHANGE|
- UFS_GDOS_FONTS|
- UFS_PROP_FONTS;/*|
- UFS_WIND_DIALOG;*/
-
- if (ufsl->id == xUFS_ID)
- {
- if ((ufsl->version <= 0x103))
- {
- ret = ufsl->font_selexinput(handle, flags, titel,
- "info", 1, 1, &f_id, &f_size,
- &width, &attr, &color, &skew);
- }
- else
- {
- ret = ufsl->font_selexinput(handle, flags, titel,
- "info", 1, 1, &f_id, &f_size,
- &width, &attr, &color, &skew);
- }
- }
- else
- {
- ufsl->dialtyp = UFS_DIALOG;/*WINDOW;*/
- ret = ufsl->fontsel_input(handle, font->Anz, (flags & UFS_PROP_FONTS) != 0,
- "info", &f_id, &f_size);
- }
- if (ret == UFS_OK)
- {
- font->ID = f_id;
- font->Size = f_size;
- for (d = 1; d <= 100; d++)
- if (font->ID == vqt_name(handle, d, font->Name))
- {
- font->Index = d;
- break;
- }
- return TRUE;
- }
- return FALSE;
- }
- else
- {
- if (note(1, NOUFSL) == 2)
- return FALSE;
- }
- }
-
- /*
- * Bevor wir den qed-FS benutzen, erst mal nachschauen, ob AES ein FS
- * kann.
- * (Bisher nur MagiC ab V4)
- */
- if (appl_xgetinfo(7, &i, &d, &d, &d) && (i & 0x04) && show_font)
- {
- VOID *fnt_ptr;
- WORD check, m4_handle, workout[57];
- LONG ratio = 1l << 16,
- id = f_id,
- size = (LONG) f_size << 16;
-
- /*
- * Da MagiC an der Workstation 'rumfingert, öffnen wir einfach
- * eine neue, nur für die Auswahl!
- */
- m4_handle = open_vwork(workout);
- fnt_ptr = fnts_create(m4_handle, 0, (FNTS_BTMP|FNTS_OUTL|FNTS_MONO|FNTS_PROP),
- (FNTS_3D), "The quick brown...", NULL);
-
- ret = fnts_do(fnt_ptr, FNTS_BSET, id, size, ratio, &check, &id, &size, &ratio);
- fnts_delete(fnt_ptr, 1);
- v_clsvwk(m4_handle);
-
- if (ret == FNTS_OK|| ret == FNTS_SET)
- {
- font->ID = (WORD) id;
- font->Size = (WORD) (size >> 16);
- for (d = 1; d <= 100; d++)
- if (font->ID == vqt_name(vdi_handle, d, font->Name))
- {
- font->Index = d;
- break;
- }
- return TRUE;
- }
- return FALSE;
- }
-
-
- /* interner Fontselector */
-
- f_nr = font->Index;
- strcpy(name, font->Name);
- fill_ptext (fontsel, FNAME, name);
- set_fsize(handle, f_id, f_size);
- if (show_font)
- undo_flags(fontsel, FTEST, HIDETREE);
- else
- do_flags(fontsel, FTEST, HIDETREE);
- open_dial(fontsel, FALSE, NULL, &dial);
- dial_draw(&dial);
- do
- {
- if (show_font)
- {
- RECT s;
-
- objc_rect (fontsel, FTEST, &s, FALSE); /* Box kann verschoben worden sein */
- Hide_mouse();
- set_clip(TRUE, &s);
- clr_area(&s);
- v_gtext(handle, s.x, s.y, "Test");
- Show_mouse();
- }
- antw = dial_do(&dial, NULL) & 0x7FFF;
- if (antw == FLEFT)
- {
- WORD i, f_nr_bak;
-
- f_nr_bak = f_nr;
- while (f_nr > 1)
- {
- f_nr--;
- i = vqt_name(handle, f_nr, name);
- if (i >= 0)
- break;
- }
- if (i >= 0)
- {
- f_id = i;
- name[32] = EOS;
- fill_ptext (fontsel, FNAME, name);
- draw_Objc(fontsel, FNAME, 1);
- f_size = set_fsize(handle,f_id,f_size);
- draw_Objc(fontsel, FGROESSE, 1);
- }
- else
- f_nr = f_nr_bak;
- }
- else if (antw == FRIGHT)
- {
- WORD i, f_nr_bak;
-
- f_nr_bak = f_nr;
- while (f_nr <= font->Anz)
- {
- f_nr++;
- i = vqt_name(handle, f_nr, name);
- if (i >= 0)
- break;
- }
- if (i >= 0)
- {
- f_id = i;
- name[32] = EOS;
- fill_ptext (fontsel, FNAME, name);
- draw_Objc(fontsel, FNAME, 1);
- f_size = set_fsize(handle,f_id,f_size);
- draw_Objc(fontsel, FGROESSE, 1);
- }
- else
- f_nr = f_nr_bak;
- }
- else if (antw == GLEFT)
- {
- f_size = prev_fsize(handle,f_size);
- f_size = set_fsize(handle,f_id,f_size);
- draw_Objc(fontsel, FGROESSE, 1);
- }
- else if (antw == GRIGHT)
- {
- f_size = next_fsize(handle,f_size);
- f_size = set_fsize(handle,f_id,f_size);
- draw_Objc(fontsel, FGROESSE, 1);
- }
- select_objc(fontsel, antw, FALSE);
- draw_Objc(fontsel, antw, 1);
- }
- while (antw != FOOK && antw != FORAUS);
- dial_end(&dial);
- if (antw == FOOK)
- {
- font->ID = f_id;
- font->Index = f_nr;
- font->Size = f_size;
- strcpy(font->Name, name);
- }
- else /* alte Werte wieder setzen */
- {
- WORD ret;
-
- vst_font(handle, font->ID);
- vst_point(handle, font->Size, &ret, &ret, &ret, &ret);
- }
- Last_mouse();
- return (antw == FOOK);
- }
-
-
- VOID get_systemfont(WORD f_anz)
- {
- WORD d, i;
-
- get_sysfnt(vdi_handle, &sys_font_id, &sys_font_size, &d, &d);
- vst_font (vdi_handle, sys_font_id);
- vst_point(vdi_handle, sys_font_size, &d, &d, &d, &d);
- winFont.ID = sys_font_id;
- for (i = 1; i <= 100; i++)
- if (winFont.ID == vqt_name(vdi_handle, i, winFont.Name))
- {
- winFont.Index = i;
- break;
- }
- winFont.Size = sys_font_size;
- winFont.Anz = f_anz;
- winFont.prop = FALSE;
-
- font_change();
- }
-
- GLOBAL VOID font_change(VOID)
- {
- WORD i, ret, w1, w2, dummy2, dummy1[5], dummy3[3];
-
- /* gl_wchar und gl_hchar werden NUR hier verändert */
- vst_font(vdi_handle, winFont.ID);
- winFont.Size = vst_point (vdi_handle, winFont.Size, &i, &i, &gl_wchar, &gl_hchar);
-
- for (i = 1; i <= 100; i++)
- if (winFont.ID == vqt_name(vdi_handle, i, winFont.Name))
- {
- winFont.Index = i;
- break;
- }
-
- vqt_width(vdi_handle,'M',&w1,&ret,&ret);
- vqt_width(vdi_handle,'I',&w2,&ret,&ret);
- winFont.prop = (w1 != w2);
-
- vqt_fontinfo(vdi_handle, &min_ascii, &max_ascii, dummy1, &dummy2, dummy3);
- if (min_ascii <= 0)
- min_ascii = 1;
-
- /* Alle Fenster updaten */
- get_all_windows(NIL, SRCH_ANY, do_font_change);
- }
-